<template>
	<el-card>
	<el-container>
		<el-aside width="220px">
			<el-tree ref="category"
					 class="menu"
					 node-key="label"
					 :data="category"
					 :default-expanded-keys="['操作日志']"
					 current-node-key="操作日志"
					 :default-expand-all="true"
					 @node-click="updateLog"
					 :highlight-current="true"
					 :expand-on-click-node="false">
			</el-tree>
		</el-aside>
		<el-container>
			<el-main class="nopadding">
				<el-container>
					<el-header style="height: auto;">
						<sc-select-filter :data="filterData" :label-width="80" @on-change="filterChange"></sc-select-filter>
					</el-header>
					<el-main class="nopadding">
						<scTable ref="table" :apiObj="apiObj" stripe highlightCurrentRow>
							<el-table-column label="#" prop="id" width="100"></el-table-column>
							<el-table-column label="事件类型" prop="eventName" width="150"></el-table-column>
							<el-table-column label="客户端IP" prop="ip" width="150"></el-table-column>
							<el-table-column label="相关人员" prop="createUserName" width="150"></el-table-column>
							<el-table-column label="日志时间" prop="createTime" width="170"></el-table-column>
							<el-table-column label="日志摘要" prop="remark" :show-overflow-tooltip="true"></el-table-column>
						</scTable>
					</el-main>
				</el-container>
			</el-main>
		</el-container>
	</el-container>
	</el-card>
</template>

<script>
import scSelectFilter from '@/components/scSelectFilter'
export default {
	name: 'User Operation Log',
	components: {
		scSelectFilter
	},
	data() {
		return {
			filterData: [
				{
					title: "日期范围",
					key: "date",
					multiple: false,
					options: [
						{
							label: "全部",
							value: ""
						},
						{
							label: "今日",
							value: "1"
						},
						{
							label: "昨日",
							value: "2"
						},
						{
							label: "一周内",
							value: "3"
						},
						{
							label: "一月内",
							value: "4"
						},
						{
							label: "一月前",
							value: "5"
						}
					]
				}
			],
			category: [
				{
					label: '操作日志',
					children: [
						{value:'1',label: '用户登陆'},
						{value:'2',label: '用户注销'},
						{value:'3001',label: '更新密码'},
						{value:'4003',label: '更新个人信息'}
					]
				}
			],
			apiObj: this.$API.system.sysLog.list,
			search: {
				date:'',
				keyword: "",
				eventType:""
			}
		}
	},
	methods: {
		filterChange(data){
			this.search.date = data.date;
			this.$refs.table.upData(this.search)
		},
		updateLog(item)
		{
			this.search.eventType = item.value;
			this.$refs.table.upData(this.search)
		},
	}
}
</script>

<style>
</style>
